import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const viewRouter = new Router({
  routes: [
    {
      path: '/routerPledge2',
      component: ()=> import('src/views_token/routerPledge2.vue'),
      meta: {
        title: '路由器挖矿质押'
      }
    },
    {
      path: '/explain',
      component: ()=> import('src/views_token/tokenBorrowExplain.vue'),
      meta: {
        title: '租借说明'
      }
    },
    {
      path: '/borrowpub',
      component: ()=> import('src/views_token/tokenBorrowPub.vue'),
      meta: {
        title: '我的发布'
      }
    },
    {
      path: '/borrowOrderOut',
      component: ()=> import('src/views_token/tokenBorrowOrderOut.vue'),
      meta: {
        title: '发布租用订单'
      }
    },
    {
      path: '/borrowOrder',
      component: ()=> import('src/views_token/tokenBorrowOrder.vue'),
      meta: {
        title: '出租订单'
      }
    },
    {
      path: '/drawBond',
      component: ()=> import('src/views_token/tokenDrawBond.vue'),
      meta: {
        title: '提取保证金'
      }
    },
    {
      path: '/addBond',
      component: ()=> import('src/views_token/tokenAddBond.vue'),
      meta: {
        title: '增加保证金'
      }
    },
    {
      path: '/order',
      component: ()=> import('src/views_token/tokenOrder.vue'),
      meta: {
        title: '令牌订单'
      }
    },
    {
      path: '/',
      component: ()=> import('src/views_token/token.vue'),
      meta: {
        title: ''
      }
    },
    /*{
      path: '/miner',
      component: ()=> import('src/views_token/tokenBecomeMiner.vue'),
      meta: {
        title: '成为矿工'
      }
    },*/
    {
      path: '/miner',
      component: ()=> import('views_app/nodeDeposit.vue'),
      meta: {
        title: '成为矿工'
      }
    },
    {
      path: '/newMining',
      component: ()=> import('src/views_token/newMining.vue'),
      meta: {
        title: '挖矿看板'
      }
    },
    {
      path: '/profitDetail',
      component: ()=> import('src/views_token/profitDetail.vue'),
      meta: {
        title: '收益明细'
      }
    },
    {
      path: '/manage',
      component: ()=> import('src/views_token/tokenManage.vue'),
      meta: {
        title: '令牌管理'
      }
    },
    {
      path: '/borrow',
      component: ()=> import('src/views_token/tokenBorrow.vue'),
      meta: {
        title: '挖矿令牌租借'
      }
    },
    {
      path: '/pledge',
      component: ()=> import('src/views_token/tokenPledge.vue'),
      meta: {
        title: ''
      }
    },
    {
      path: '/tokenBuy',
      component: ()=> import('src/views_token/tokenBuy.vue'),
      meta: {
        title: '挖矿令牌购买'
      }
    },
    {
      path: '/tokenSell',
        component: ()=> import('src/views_token/tokenSell.vue'),
      meta: {
        title: '挖矿令牌出售'
      }
    },
    {
      path: '/issueOrder',
      component: ()=> import('src/views_token/issueOrder.vue'),
      meta: {
        title: '发布出售订单'
      }
    },
    {
      path: '/buybackQueue',
      component: ()=> import('src/views_token/buybackQueue.vue'),
      meta: {
        title: '官方回购队列'
      }
    },
    {
      path: '/routerPledge',
      component: ()=> import('src/views_token/routerPledge.vue'),
      meta: {
        title: '路由器挖矿质押'
      }
    }
  ]
})


viewRouter.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  let uid = to.query.uid || localStorage.getItem('uid')
  let token = to.query.token || localStorage.getItem('token')


  next()
  setTimeout(()=>{
    localStorage.setItem('uid', uid)
    localStorage.setItem('token', token)
  },40)

})


export default viewRouter
